<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>

    <style>
        v-enter,
        v-leave-to {
            opacity: 0;
            transform: translateX(130px)
        }
        
        v-enter-active,
        v-leave-active {
            transition: all 0.5s ease
        }
    </style>
</head>
<!--该案例实现组件切换的动画，没有实现，和视频代码一样
    使用mode:'out-in'可以使动画先出去再进来
-->

<body>

    <div id='a'>
        <input type="button" value="注册" @click='register1'>
        <input type="button" value="登录" @click='login1'>
        <transition mode='out-in'>
            <component :is='appear'></component>
        </transition>


    </div>

    <template id='re'>
        <div>
            <p>注册模块</p>
        </div>
    </template>
    <template id='lo'>
        <div>
            <p>登录模块</p>
        </div>
    </template>
    <script>
        Vue.component('register', {
            template: '#re',

        })
        Vue.component('login', {
            template: '#lo',

        })
        new Vue({
            el: '#a ',
            data: {
                appear: 'register'
            },
            methods: {
                login1: function() {
                    this.appear = 'login';

                },
                register1: function() {
                    this.appear = 'register';
                }
            }

        })
    </script>
</body>

</html>